package com.iqiyi.pps.epg.core.service.config;

import com.iqiyi.pps.epg.core.dao.config.ConfigDao;
import com.iqiyi.pps.epg.core.model.config.Config;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ConfigServiceImpl implements ConfigService {
    @Autowired
    private ConfigDao configDao;



    @Override
    public Config getByKey(String key) {
        Criteria crit = configDao.createCriteria();
        crit.add(Restrictions.eq("key", key));
        crit.setMaxResults(1);
        List list = configDao.find(crit);
        return list.size() > 0 ? (configDao.find(crit)).get(0) : null;
    }
}
